package com.sx.zongzhi.presenter;

import android.content.Context;

import com.sx.zongzhi.bean.EconomicOrganizionBean;
import com.sx.zongzhi.modle.ApiManager;
import com.sx.zongzhi.modle.HeadParamBean;
import com.sx.zongzhi.net.BaseCallBack;
import com.sx.zongzhi.net.BasePageListBean;
import com.sx.zongzhi.net.BaseResult;
import com.sx.zongzhi.utils.BaseUtil;
import com.sx.zongzhi.view.IEconomicOrganizationView;

import java.util.Map;

/**非公有制经济组织
 * Created by admin on 2017/12/8.
 */

public class EconomicOrganizationPest {
    private IEconomicOrganizationView iEconomicOrganizationView;

    public EconomicOrganizationPest( IEconomicOrganizationView iEconomicOrganizationView) {
        this.iEconomicOrganizationView=iEconomicOrganizationView;
    }

    /**
     * searchNewEconomicOrganizationsVo.name	否	string	经济组织名称
     searchNewEconomicOrganizationsVo.style	否	string	经济组织类型
     searchNewEconomicOrganizationsVo.residence	否	string	经济组织地址
     searchNewEconomicOrganizationsVo.licenseNumber	否	string	工商执照号码
     searchNewEconomicOrganizationsVo.chief	否	string	法人姓名
     searchNewEconomicOrganizationsVo.telephone	否	string	法人电话号码
     searchNewEconomicOrganizationsVo.mobileNumber	否	string	法人手机号码
     searchNewEconomicOrganizationsVo.chiefSafe	否	string	治保负责人姓名
     searchNewEconomicOrganizationsVo.telephoneSafe	否	string	治保负责人电话号码
     searchNewEconomicOrganizationsVo.mobileNumberSafe	否	string	治保负责人手机号码
     searchNewEconomicOrganizationsVo.enterpriseTelephone	否	string	企业电话号码
     searchNewEconomicOrganizationsVo.enterpriseMobile	否	string	企业手机号码
     orgId	否	string	网格id(根据网格筛选:不填写默认为当前登陆用户所在网格)
     * @param context
     * @param page
     * @param rows
     */
    public void getEconomicOrganizationList(Context context, int page, int rows, String name,
                               String style, String residence, String licenseNumber,
                               String chief, String telephone,String mobileNumber,String chiefSafe,
                               String telephoneSafe, String mobileNumberSafe, String enterpriseTelephone,
                               String enterpriseMobile,String orgId){
        Map<String,Object> map = HeadParamBean.getHead(context);
        map.put("page", page);
        map.put("rows", rows);
        if (!BaseUtil.isEmpty(name)){
            map.put("searchNewEconomicOrganizationsVo.name",name);
        }
        if (!BaseUtil.isEmpty(style)){
            map.put("searchNewEconomicOrganizationsVo.style",style);
        }
        if (!BaseUtil.isEmpty(residence)){
            map.put("searchNewEconomicOrganizationsVo.residence",residence);
        }
        if (!BaseUtil.isEmpty(licenseNumber)){
            map.put("searchNewEconomicOrganizationsVo.licenseNumber",licenseNumber);
        }
        if (!BaseUtil.isEmpty(chief)){
            map.put("searchNewEconomicOrganizationsVo.chief",chief);
        }
        if (!BaseUtil.isEmpty(telephone)){
            map.put("searchNewEconomicOrganizationsVo.telephone",telephone);
        }
        if (!BaseUtil.isEmpty(mobileNumber)){
            map.put("searchNewEconomicOrganizationsVo.mobileNumber",mobileNumber);
        }
        if (!BaseUtil.isEmpty(chiefSafe)){
            map.put("searchNewEconomicOrganizationsVo.chiefSafe",chiefSafe);
        }
        if (!BaseUtil.isEmpty(telephoneSafe)){
            map.put("searchNewEconomicOrganizationsVo.telephoneSafe",telephoneSafe);
        }
        if (!BaseUtil.isEmpty(mobileNumberSafe)){
            map.put("searchNewEconomicOrganizationsVo.mobileNumberSafe",mobileNumberSafe);
        }
        if (!BaseUtil.isEmpty(enterpriseTelephone)){
            map.put("searchNewEconomicOrganizationsVo.enterpriseTelephone",enterpriseTelephone);
        }
        if (!BaseUtil.isEmpty(enterpriseMobile)){
            map.put("searchNewEconomicOrganizationsVo.enterpriseMobile",enterpriseMobile);
        }
        if (!BaseUtil.isEmpty(orgId)){
            map.put("orgId",orgId);
        }
        new ApiManager().getEconomicOrganizationList(map, new BaseCallBack<BaseResult<BasePageListBean<EconomicOrganizionBean>>>() {
            @Override
            public void onSuccess(BaseResult<BasePageListBean<EconomicOrganizionBean>> response) {
                iEconomicOrganizationView.getEconomicOrganizationListSuccess(response.getData().permission,response.getData().rows,response.getData().getTotal());
            }
            @Override
            public void onFailures(String message) {
                iEconomicOrganizationView.showError(message);
            }
        });
    }
}
